package com.highspeed.bdk.gateway.socket.analyze.message.gui.resolver;

import com.highspeed.bdk.gateway.Util;
import com.highspeed.bdk.gateway.socket.analyze.message.gui.base.MessageResolver;

import java.util.Map;

/**
 * typedef struct _phylinkStatics
 * {
 * U32 linkSum;//link的总条数
 * U16 oneLinkDataLen;//每条链路的数据的长度
 * U16 reserved;
 * OnePhyLinkStatics data[0];//可变长，用于顺序存贮每条链路的数据
 * } PhyLinkStaticsFbData;
 */
public class PhysicalLinkStaticsResolver0x27 extends MessageResolver {

    @Override
    protected Map doResolveBody(byte[] response) {
        int linkSum = Util.getInt(response, getOffset());
        offset4();
        logger.info("linkSum............." + linkSum);
        short oneLinkDataLen = Util.getShort(response, getOffset());
        offset2();
        logger.info("oneLinkDataLen............." + oneLinkDataLen);
        short reserved = Util.getShort(response, getOffset());
        offset2();
        logger.info("reserved............." + reserved);
        OnePhyLinkStaticsResolver onePhyLinkStaticsResolver = new OnePhyLinkStaticsResolver();
        onePhyLinkStaticsResolver.setContainer(getContainer());
        for (int i = 0; i < linkSum; i++) {
            logger.info("解析第" + i + "个物理链路统计信息");
            onePhyLinkStaticsResolver.doResolveBody(response);
        }
        return getContainer();
    }
}
